
//根据name全选
function selAll(objNm){
	var objs=document.getElementsByName(objNm);
    for(objIndex=0; objIndex <objs.length; objIndex++){
    	objs[objIndex].checked = true;
    }
}

//根据name反选
function unSelectAll(objNm){
	var objs=document.getElementsByName(objNm);
    for(objIndex=0; objIndex <objs.length; objIndex++){
    	if(objs[objIndex].checked == true){
    		objs[objIndex].checked = false;
    	} else {
    		objs[objIndex].checked = true;
    	}
    }
}

//根据name全部取消选择
function cancelAll(objNm){
	var objs=document.getElementsByName(objNm);
    for(objIndex=0; objIndex <objs.length; objIndex++){
    		objs[objIndex].checked = false;  	
    }
}


/**	
 * 翻页效果实现
 * btnFlg 标志符-1：首页；-2：上一页；-3：下一页；-4：末页；-5：跳转到固定页
 * curId 当前页的Id
 * totalId 总页数的Id
 * chgPageNumId 跳转页文本框的id
 */
function chgPage(btnFlg,curId,totalId,chgPageNumId){

	alert("跳进common中的翻页函数"+$(curId).val());
	  var curPage = parseInt($(curId).val());
	  var totalPages = parseInt($(totalId).val());
	  if(btnFlg == 1){
		  if(curPage==1){
		    alert("已经是首页");		   
		    return 0;
		  }
		  alert(1);
		  // 设置当前页为第一页$(curId).val(1)
		  return 1;
		} else if(btnFlg == 2){
		  if(curPage==1){
		    alert("已经是第一页");
		    return 0;
		  }
		  // 设置当前页为当前页-1$(curId).val(curPage - 1)
		  return 2;
		} else if(btnFlg == 3){
		  if(curPage==totalPages){
		    alert("已经是最后一页");
		    return 0;
		  }
		  // 设置当前页为当前页+1 $(curId).val(curPage + 1)
		  return 3;
	  } else if(btnFlg == 4){
	  		if(curPage==totalPages){
		    alert("已经是末页");
		    return 0;
		  }
		  // 设置当前页为最后一页$(curId).val(totalPages)
	  		
	  		return 4;
	  } else if(btnFlg == 5){
		  alert($(chgPageNumId).val());
	  	var chgPageNum = parseInt($(chgPageNumId).val());
	  	if(chgPageNum<1 || chgPageNum>totalPages){
	  	  alert("您输入的页码不存在，请重新输入");
		    return 0;
	  	} else if(curPage==chgPageNum){
		    alert("当前页已经是您所要跳转的页面了");
		    return 0;
		  }
		  // 设置当前页为最后一页$(curId).val(chgPageNum)
	  	return 5;
	  }	
	}

//没用

/*function viewArc(aid){
	if(aid==0) aid = getOneItem();
	window.open("archives.asp?aid="+aid+"&action=viewArchives");
}
function editArc(aid){
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=editArchives";
}
function updateArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=makeArchives&qstr="+qstr+"";
}
function checkArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=checkArchives&qstr="+qstr+"";
}
function moveArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=moveArchives&qstr="+qstr+"";
}
function adArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=commendArchives&qstr="+qstr+"";
}
function delArc(aid){
	var qstr=getCheckboxItem();
	if(aid==0) aid = getOneItem();
	location="archives.asp?aid="+aid+"&action=delArchives&qstr="+qstr+"";
}

//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			if(allSel=="")
				allSel=document.form2.id[i].value;
			else
				allSel=allSel+"`"+document.form2.id[i].value;
		}
	}
	return allSel;
}

//获得选中其中一个的id
function getOneItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
				allSel = document.form2.id[i].value;
				break;
		}
	}
	return allSel;
}
function selAll()
{
	for(i=0;i<document.form2.id.length;i++)
	{
		if(!document.form2.id[i].checked)
		{
			document.form2.id[i].checked=true;
		}
	}
}
function noSelAll()
{
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			document.form2.id[i].checked=false;
		}
	}
}*/